public class sushu {
    public static void main(String[] args) {
        System.out.println(bf(100));
        System.out.println(ai(100));
    }
//暴力算法
    private static int bf(int n){
        int count = 0;
        for(int i=2;i<n;i++){
            count += isPrime(i) ? 1 : 0;
        }
        return count;
    }

    private static boolean isPrime(int x) {
        for(int i=2;i<x;i++){
            if (x%i==0){
                return false;
            }
        }
        return true;
    }


    //埃筛法
    private static int ai(int n){
        boolean iPrime[] = new boolean[n];//素数为false
        int count=0;
        for(int i=2;i<n;i++){
            if(!iPrime[i]){
                count++;
                for(int j=i*i;j<n;j+=i){
                    iPrime[j]=true;
                }
            }
        }
        return count;
    }
}
